cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

enable_testing()

find_package(Catch2 REQUIRED CONFIG)

if(WITH_PREFIX)
    set(SRC_STANDALONE 300-standalone-with-prefix.cpp)
    set(SRC_BENCHMARK 400-benchmark-with-prefix.cpp)
else()
    set(SRC_STANDALONE 100-standalone.cpp)
    set(SRC_BENCHMARK 200-benchmark.cpp)
endif()

add_executable(standalone 000-CatchMain.cpp ${SRC_STANDALONE})
target_link_libraries(standalone PRIVATE Catch2::Catch2)
target_compile_features(standalone PRIVATE cxx_std_11)
add_test(NAME standalone COMMAND standalone)
if(WITH_MAIN)
    add_executable(standalone_with_main ${SRC_STANDALONE})
    target_link_libraries(standalone_with_main PRIVATE Catch2::Catch2WithMain)
    target_compile_features(standalone_with_main PRIVATE cxx_std_11)
    add_test(NAME standalone_with_main COMMAND standalone_with_main)
endif()
if(WITH_BENCHMARK)
    add_executable(benchmark ${SRC_BENCHMARK})
    target_link_libraries(benchmark PRIVATE Catch2::Catch2WithMain)
    target_compile_features(benchmark PRIVATE cxx_std_11)
    add_test(NAME benchmark COMMAND benchmark)
endif()
